package Formularios;

import javax.swing.JFrame;
import javax.swing.JLabel;

import java.awt.Font;
import java.awt.SystemColor;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JTextField;

import br.ifpi.CalculadoraSalario.Cargo;
import br.ifpi.CalculadoraSalario.Funcionario;
import br.ifpi.CalculadoraSalario.FuncionarioLista;

import javax.swing.JButton;

public class Cadastro {
	private JFrame tela = new JFrame("Cadastro");
	private JTextField textNome;
	private JTextField textEmail;
	private JTextField textSalarioBase;
	public static String item,nome1,email1,cargo1,salario1;
	public static Funcionario dadosFuncionario;
	public static FuncionarioLista funcionarioLista = new FuncionarioLista();
	/**
	 * @wbp.parser.entryPoint
	 */
	public void form(){
		tela.setSize(589,482);
		tela.getContentPane().setLayout(null);
		
		Label label = new Label("Cadastro de Funcion\u00E1rios");
		label.setBounds(0, 0, 573, 24);
		label.setBackground(SystemColor.info);
		label.setFont(new Font("Dialog", Font.PLAIN, 14));
		label.setAlignment(Label.CENTER);
		tela.getContentPane().add(label);
		
		JLabel lblCargo = new JLabel("CARGO");
		lblCargo.setBounds(104, 82, 46, 14);
		tela.getContentPane().add(lblCargo);
		
		Cargo listaCargos = new Cargo();
		@SuppressWarnings("unchecked")
		JComboBox comboCargo = new JComboBox(listaCargos.cargo);
		item= (String) comboCargo.getSelectedItem();
		comboCargo.setBounds(194, 79, 151, 20);
		tela.getContentPane().add(comboCargo);
		
		
		JLabel lblNome = new JLabel("NOME");
		lblNome.setBounds(104, 136, 46, 14);
		tela.getContentPane().add(lblNome);
		
		JLabel lblNewLabel = new JLabel("E-MAIL");
		lblNewLabel.setBounds(104, 161, 46, 14);
		tela.getContentPane().add(lblNewLabel);
		
		JLabel lblSalrioBase = new JLabel("SAL\u00C1RIO BASE");
		lblSalrioBase.setBounds(104, 186, 94, 14);
		tela.getContentPane().add(lblSalrioBase);
		
		textNome = new JTextField();
		textNome.setBounds(220, 133, 238, 20);
		tela.getContentPane().add(textNome);
		textNome.setColumns(10);
		
		textEmail = new JTextField();
		textEmail.setBounds(220, 158, 238, 20);
		tela.getContentPane().add(textEmail);
		textEmail.setColumns(10);
		
		textSalarioBase = new JTextField();
		textSalarioBase.setBounds(219, 183, 239, 20);
		tela.getContentPane().add(textSalarioBase);
		textSalarioBase.setColumns(10);
		
		JButton btnSalvar = new JButton("Salvar");
		btnSalvar.setBounds(343, 271, 89, 23);
		btnSalvar.addActionListener(
				new ActionListener(){
				public void actionPerformed(ActionEvent e){
				int id=0;
				switch (item){
				case "DESENVOLVEDOR":{
					id=1;
					break;
				}
				case "DBA":{
					id=2;
					break;
				}
				case "TESTADOR":{
					id=3;
					break;
				}
				case "GERENTE":{
					id=4;
					break;
					
				}
				}
				nome1=textNome.getText();
				email1=textEmail.getText();
				salario1=textSalarioBase.getText();
				cargo1=item;
				dadosFuncionario = new Funcionario(nome1,email1,salario1,cargo1,id);
				
				funcionarioLista.gravar(dadosFuncionario);
				textNome.setText(null);
				textEmail.setText(null);
				textSalarioBase.setText(null);
				
				
				
				
				}
				}
				);
		tela.getContentPane().add(btnSalvar);
		tela.setVisible(true);
	}
}
